package com.coms514.scheduleme;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CaregiverAdapter extends BaseAdapter {
	
	private Context context;
	private ArrayList<String> id;
	private ArrayList<String> name;
	private ArrayList<String> email;
	private ArrayList<String> phone;

	public CaregiverAdapter(Context c, ArrayList<String> id, ArrayList<String> name, ArrayList<String> email, ArrayList<String> phone) {
		this.context = c;
		this.id = id;
		this.name = name;
		this.email = email;
		this.phone = phone;
	}
	
	@Override
	public int getCount() {
		return id.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int pos, View child, ViewGroup parent) {
		Holder holder;
		LayoutInflater layoutInflater;

		if (child == null) {
			layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			child = layoutInflater.inflate(R.layout.caregiverlistitem, null);
			
			holder = new Holder();
			holder.nameTextView = (TextView)child.findViewById(R.id.name_entry);
			holder.emailTextView = (TextView)child.findViewById(R.id.email_entry);
			holder.phoneTextView = (TextView)child.findViewById(R.id.phone_entry);
		} else {
			holder = (Holder)child.getTag();
		}
		holder.nameTextView.setText(name.get(pos));
		holder.emailTextView.setText(email.get(pos));
		holder.phoneTextView.setText(phone.get(pos));
		
		return child;
	}
	
	public class Holder {
		TextView nameTextView;
		TextView emailTextView;
		TextView phoneTextView;
	}

	public String getId(int pos) {
		return this.id.get(pos);
	}
	
	public String getName(int pos) {
		return this.name.get(pos);
	}

	public String getEmail(int pos) {
		return this.email.get(pos);
	}

	public String getPhone(int pos) {
		return this.phone.get(pos);
	}
}
